package com.shushan.home.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * @ClassName: rewardTimeBean
 * @Desciption: 时间奖励bean
 * @author: yichaohua
 * @date: 2018-04-16
 */
public class RewardTimeBean extends NetBaseBean {

    public String name;//一级标题
    public String task;//二级标题
    public int type;
    public int practice_type;//1、同步练习 2、智能练习 3、边学边练 4、重点练习 5、难点练习 6、易错练习 7、专项练习
    public String complete_num;//完成人数
    public String training_num;//正在练习人数
    public boolean znlx;//智能练习是否有题；true有题；false无题；

    public ArrayList<Integer> timeList = new ArrayList<Integer>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        name = jsonObject.optString("name","");
        task = jsonObject.optString("task","");
        type = jsonObject.optInt("type",1);
        practice_type = jsonObject.optInt("practice_type",1);
        complete_num = jsonObject.optString("complete_num","");
        training_num = jsonObject.optString("training_num","");
        znlx = jsonObject.optBoolean("znlx",false);

        JSONArray array = jsonObject.optJSONArray("description");
        if(array != null && array.length() > 0) {
            for (int i = 0; i < array.length(); i++) {
                timeList.add(array.optInt(i));
            }
        }
    }

    public static String getTimeDes(int position,int time){
        StringBuffer sb = new StringBuffer();
        switch (position){
            case 0:
                sb.append("本次练习获得70分以下");
                break;
            case 1:
                sb.append("本次练习获得70-79分");
                break;
            case 2:
                sb.append("本次练习获得80-89分");
                break;
            case 3:
                sb.append("本次练习获得90-99分");
                break;
            case 4:
                sb.append("本次练习获得100分");
                break;
        }
        sb.append(",使用").append(String.valueOf(time)).append("分钟手机");
        return sb.toString();
    }

}
